package com.coco.admin.controller;

import com.coco.admin.pojo.TbAdmin;
import com.coco.admin.service.AdminService;
import com.coco.common.annotation.IngoreResponseAdvice;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * controller
 *
 * @Author: guofeng
 * @Date: 2021/07/14/20:46
 * @Description:
 */

@RestController
@RequestMapping("/admin")
@CrossOrigin
public class AdminController {

    @Autowired
    private AdminService adminService;

    /**
     * 增加
     *
     * @param goods
     * @return
     */
    @RequestMapping("/add")
    public void add(@RequestBody TbAdmin goods) {
        adminService.add(goods);
    }


    /**
     * 批量删除
     *
     * @param ids
     * @return
     */
    @RequestMapping("/delete")
    public void delete(Long[] ids) {
        adminService.delete(ids);
    }

    /**
     * 修改
     *
     * @param goods
     * @return
     */
    @RequestMapping("/update")
    public void update(@RequestBody TbAdmin goods) {
        adminService.update(goods);
    }

    /**
     * 获取实体
     *
     * @param id
     * @return
     */
    @RequestMapping("/findOne/{id}")
    public TbAdmin findOne(@PathVariable Long id) {
        return adminService.findOne(id);
    }


    @RequestMapping("/findName")
    public TbAdmin findName(@RequestParam("username") String username) {
        return adminService.findName(username);
    }

    /**
     * 查询全部用户
     *
     * @return
     */
    @RequestMapping("/findAll")
    public List<TbAdmin> findAll() {
        return adminService.findAll();
    }


}



